package com.csliubo.eclipse.plugin.sqlgenerator.core;

import java.util.HashMap;
import java.util.Map;

import com.csliubo.eclipse.plugin.sqlgenerator.constants.OutputFormat;
import com.csliubo.eclipse.plugin.sqlgenerator.core.resultset.ExcelResultSetHandler;
import com.csliubo.eclipse.plugin.sqlgenerator.core.resultset.ResultSetHandler;
import com.csliubo.eclipse.plugin.sqlgenerator.core.resultset.WikiResultSetHandler;
import com.csliubo.eclipse.plugin.sqlgenerator.core.writer.DataWriter;
import com.csliubo.eclipse.plugin.sqlgenerator.core.writer.ExcelWriter;
import com.csliubo.eclipse.plugin.sqlgenerator.core.writer.WikiWriter;

import static com.csliubo.eclipse.plugin.sqlgenerator.constants.OutputFormat.*;

/**
 * 数据输出类工厂
 * 
 * @author liubo
 */
public class OuputTypeFactory {

    private static final Map<OutputFormat, DataWriter>       writerMap    = new HashMap<OutputFormat, DataWriter>();
    private static final Map<OutputFormat, ResultSetHandler> resultSetMap = new HashMap<OutputFormat, ResultSetHandler>();
    static {
        writerMap.put(WIKI, new WikiWriter());
        writerMap.put(EXCEL, new ExcelWriter());

        resultSetMap.put(WIKI, new WikiResultSetHandler());
        resultSetMap.put(EXCEL, new ExcelResultSetHandler());
    }

    /**
     * 获取数据输出实例
     * 
     * @return
     */
    public static DataWriter getDataWriter(OutputFormat format) {
        return writerMap.get(format);
    }

    public static ResultSetHandler getResultSetHandler(OutputFormat format) {
        return resultSetMap.get(format);
    }
}
